﻿@using Apps.Web.Core;
@using Apps.Web;
@using Apps.Common;
@using Apps.Models.Sys;
@using Apps.Locale;
@{
    ViewBag.Title = "MIS_MailBox";
    Layout = "~/Views/Shared/_Index_Layout.cshtml";
    List<permModel> perm = null;
}
<div class="mvctool">
   <input id="txtQuery" placeholder="请输入关键字" type="text" class="searchText" />
    @Html.ToolButton("btnQuery", "fa fa-search", Resource.Query,ref perm, "Query", true)
    @Html.ToolButton("btnCreate", "fa fa-plus", Resource.Create,ref perm, "Create", true)
    @Html.ToolButton("btnEdit", "fa fa-pencil", Resource.Edit,ref perm, "Edit", true)
    @Html.ToolButton("btnDetails", "fa fa-list", Resource.Details,ref perm, "Details", true)
    @Html.ToolButton("btnDelete", "fa fa-trash", Resource.Delete,ref perm, "Delete", true)
</div>

<table>
    <tr>
        <td style="width:255px;">
            <a class="btns">发送信息</a>
        </td>
        <td><table id="List"></table></td>
    </tr>
</table>



<div id="modalwindow" class="easyui-window" style="width:800px; height:400px;" data-options="modal:true,closed:true,minimizable:false,shadow:false"></div>
@Html.Partial("~/Views/Shared/_Partial_AutoGrid.cshtml")
<script type="text/javascript">
    $(function () {
        $('#List').datagrid({
            url: '@Url.Action("GetList")?folderType=1',
            width:SetGridWidthSub(255),
            methord: 'post',
            height: SetGridHeightSub(45),
            fitColumns: true,
            sortName: 'CreateTime',
            sortOrder: 'desc',
            idField: 'Id',
            pageSize: 15,
            pageList: [15, 20, 30, 40, 50],
            pagination: true,
            striped: true, //奇偶行是否区分
            singleSelect: true,//单选模式
            //rownumbers: true,//行号
            onLoadSuccess: function(data) {
                @foreach(var r in perm){
                if (r.Category == 2) {
                    @Html.Raw("$(this).datagrid('hideColumn','" + r.KeyCode + "'); ");
                }
                }//动态根据权限隐藏列
            },
            columns: [[
                { field: 'Id', title: 'Id', width: 80,hidden:true },
                { field: 'Subject', title: '主题', width: 80,sortable:true },
                { field: 'ContentBody', title: '内容', width: 80,sortable:true },
                { field: 'Attachment', title: '附件', width: 80,sortable:true },
                { field: 'FolderType', title: '文件夹', width: 80,sortable:true,hidden:true },
                { field: 'UserId', title: '发送人', width: 80,sortable:true,hidden:true  },
                { field: 'StarFlag', title: '星号标记', width: 80,sortable:true , align: 'center', formatter: function (value) { return EnableFormatter(value) } },
                { field: 'Status', title: '状态', width: 80,sortable:true ,hidden:true },
                { field: 'CreateTime', title: '时间', width: 80,sortable:true }
            ]]
        });
    });
    //ifram 返回
    function frameReturnByClose() {
        $("#modalwindow").window('close');
    }
    function frameReturnByReload(flag) {
        if (flag)
            $("#List").datagrid('load');
        else
            $("#List").datagrid('reload');
    }
    function frameReturnByMes(mes) {
        $.messageBox5s(Lang.Tip, mes);
    }
    $(function () {
        $("#btnCreate").click(function () {
            $.modalWindow(Lang.Create, '@Url.Action("Create")', 700, 400, 'fa fa-plus');
        });
        $("#btnEdit").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $.modalWindow(Lang.Edit, '@Url.Action("Edit")?id=' + row.Id + '&Ieguid=' + GetGuid(), 700, 400, 'fa fa-pencil');
            } else { $.messageBox5s(Lang.Tip, Lang.PleaseSelectTheOperatingRecord); }
        });
        $("#btnDetails").click(function () {
            var row = $('#List').datagrid('getSelected');
            if (row != null) {
                $.modalWindow(Lang.Details, '@Url.Action("Details")?id=' + row.Id + '&Ieguid=' + GetGuid(), 700, 400, 'fa fa-list');
            } else { $.messageBox5s(Lang.Tip, Lang.PleaseSelectTheOperatingRecord); }
	        });
        $("#btnQuery").click(function () {
            var queryStr = $("#txtQuery").val();
            if (queryStr == null) {
                queryStr = "%";
            }
            $("#List").datagrid("load", { queryStr: queryStr });

        });
        $("#btnDelete").click(function () {
           dataDelete("@Url.Action("Delete")", "List");
	    });

        $(function () {
            $(window).resize(function () {
                $('#List').datagrid('resize', {

                }).datagrid('resize', {
                    width:  SetGridWidthSub(255),
                    height: SetGridHeightSub(45)
                });
            });

        });
    });
</script>

